#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
void pr_exit(int status, pid_t pid)
{
    int sig;
    if (WIFEXITED(status))
    {
        printf("process %d normal termination ,exit code status is %d\n", pid, WEXITSTATUS(status));
    }
    else if (WIFSIGNALED(status))
    {
        sig = WTERMSIG(status);
        printf("process %d abnormal termination ,signal number is %d%s\n", pid, sig,
#ifdef WCOREDUMP
               WCOREDUMP(status) ? "(core file generated)" : "");
#else
               "");
#endif
        psignal(sig, "");
    }
    else if (WIFSTOPPED(status))
    {
        sig = WSTOPSIG(status);
        printf("process %d stopped,exit code status is %d\n", pid, WEXITSTATUS(status));
    }
}

// void pr_exit(int status, pid_t pid)
// {
//     int sig;
//     if (WIFEXITED(status))
//         printf("process %d normal termination,exit code status = %d!\n", pid, WEXITSTATUS(status));
//     else if (WIFSIGNALED(status))
//     {
//         sig = WTERMSIG(status);
//         printf("process %d abnormal termination,signal number = %d %s!\n", pid, sig,
// #ifdef WCOREDUMP
//                WCOREDUMP(status) ? "(core file generated)" : "");
// #else
//                "");
// #endif
//         psignal(sig, "");
//     }
//     else if (WIFSTOPPED(status))
//     {
//         sig = WSTOPSIG(status);
//         printf("process %d stopped,signal number = %d!\n", pid, sig);
//         psignal(sig, "");
//     }
// }